package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.LineInfo;
import org.xx.armory.objectparser.ParsedObject;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import static org.apache.commons.lang3.StringUtils.trimToEmpty;

public class MenuModel
        extends ParsedObject {
    private final String title;
    private final char mnemonic;
    private final List<Object> children;

    /**
     * 构造解析对象。
     *
     * @param lineInfo
     *         源文件中的位置信息。
     */
    protected MenuModel(
            LineInfo lineInfo,
            String title,
            char mnemonic,
            Collection<Object> children
    ) {
        super(lineInfo);

        this.title = trimToEmpty(title);
        this.mnemonic = mnemonic;
        this.children = children != null ? new ArrayList<>(children) : Collections.emptyList();
    }

    public final String getTitle() {
        return this.title;
    }

    public final char getMnemonic() {
        return this.mnemonic;
    }

    public final List<Object> getChildren() {
        return this.children;
    }
}
